import {getSetting} from "@/api/setting";
import {titleControl} from "@/utils";
export default {
    namespaced: true,
    state: {
      loading: false,
      data: null
    },
    mutations: {
        setLoading(state, data) {
            state.loading = data;
        },
        setData(state, data) {
            state.data = data;
        }
    },
    actions: {
        async getSetting(ctx) {
            ctx.commit("setLoading", true);
            const resp = await getSetting();
            if (resp.siteTitle) {
                titleControl.setSideTitle(resp.siteTitle);
            }
            ctx.commit("setData", resp);
            ctx.commit("setLoading", false);
        }
    }
}
